package com.zyk.leetcode;

import java.util.Arrays;

/**
 * @author zhangsan
 * @date 2021/4/15 16:35
 */
public class C1720 {

    // https://leetcode-cn.com/problems/decode-xored-array/
    public int[] decode(int[] encoded, int first) {
        int[] decode = new int[encoded.length + 1];
        decode[0] = first;
        for (int i = 1; i < decode.length; i++)
            decode[i] = encoded[i - 1] ^ decode[i - 1];
        return decode;
    }


    // for test
    public static void main(String[] args) {

        C1720 test = new C1720();
        int[] encoded = {1, 2, 3};
        int first = 1;
        int[] decode = test.decode(encoded, first);
        System.out.println(Arrays.toString(decode));
    }

}
